package com.bestcem.xm.qdes.controller;

import com.bestcem.xm.common.core.domain.web.XmResultJson;
import com.bestcem.xm.qdes.entity.QdesNameList;
import com.bestcem.xm.qdes.service.QdesNameListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@Api(tags = "问卷编辑-个人信息白名单")
@RestController
@RequiredArgsConstructor
@RequestMapping("/qdes/namelist")
public class QdesNameListController {
    private @NonNull QdesNameListService qdesNamelistService;

    /**
     * 设置问卷姓名，邮箱白名单
     *
     * @return
     */
    @ApiOperation(value = "设置白名单，邮箱")
    @PutMapping("/")
    public XmResultJson<Map> putNameList(@RequestBody QdesNameList qdesNamelist) {
        return XmResultJson.success(qdesNamelistService.putNameList(qdesNamelist));
    }

    /**
     * 获取问卷姓名，邮箱白名单
     *
     * @return
     */
    @ApiOperation(value = "获取白名单，邮箱")
    @GetMapping("/")
    public XmResultJson<QdesNameList> getNameList(@RequestParam(value = "project_id") String projectId,
                                                  @RequestParam(value = "gid") String gid,
                                                  @RequestParam(value = "version") String version) {
        return XmResultJson.success(qdesNamelistService.getNameList(projectId,gid,version));
    }
}
